//
//  SFAudioPlayer.h
//  Test
//
//  Created by xueshan1 on 2018/11/13.
//  Copyright © 2018年 xueshan1. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "ISFAudioPlayerProtocol.h"
#define kWeakSelf __weak __typeof(&*self)weakSelf = self;


typedef NS_ENUM(NSUInteger,SFAudioPlayerState){
    SFAudioPlayerState_Stopped,
    SFAudioPlayerState_Playing,
    SFAudioPlayerState_Pause,
    SFAudioPlayerState_Failed,
    SFAudioPlayerState_Buffering

};
typedef NS_ENUM(NSUInteger, SFAudioPlayerSessionCategory) {
    SFAudioPlayerSessionCategory_Ambient,    //用于播放,随用户锁屏和静音而静音,不终止其他播放声音
    SFAudioPlayerSessionCategory_SoloAmbient,//用于播放,随用户锁屏和静音而静音,终止其他播放声音
    SFAudioPlayerSessionCategory_Playback,   //用于播放,不随用户锁屏和静音而静音,终止其他播放声音(需设置后台播放background mode)
};

NS_ASSUME_NONNULL_BEGIN

@interface SFAudioPlayer : NSObject

#pragma mark --状态
//播放器状态
@property(nonatomic,readonly,assign)SFAudioPlayerState playState;
//播放进度
@property(nonatomic,assign)CGFloat sf_progress;
//进度变化回调
@property(nonatomic,copy)void(^progressChangeBlock)(CGFloat sf_progress);
//当前播放时长
@property(nonatomic,assign)CGFloat sf_currentTime;
//总时长
@property(nonatomic,assign)CGFloat sf_totalTime;
//缓冲进度
@property(nonatomic,assign)CGFloat sf_bufferProgress;

#pragma mark --控制
//播放类别
@property(nonatomic,assign)SFAudioPlayerSessionCategory sessionCategory;
//是否循环播放 default NO
@property(nonatomic,assign)BOOL isRecyclePlay;
//播放速度
@property(nonatomic,assign)CGFloat sf_rate;
//设置播放进度 0~1
@property(nonatomic,assign)CGFloat progressValus;
//自定义缓存default NO (系统将不会自动加载)
@property(nonatomic,assign)BOOL needCustomeCache;




@property(nonatomic,weak)id<ISFAudioPlayerDelegate>delegate;

+ (instancetype)shareInstance;
//初始化
- (void)initPlayer;
//播放一个音频
- (void)sf_playAudioWithURL:(NSURL *)audioURL;
- (void)sf_playAudioWithURLString:(NSString *)audioURLString;

//播放(第一次播放不需要调用)
- (void)sf_audioPlay;
//暂停
- (void)sf_audioPause;
//释放播放器
- (void)sf_deallocPlayer;

@end

NS_ASSUME_NONNULL_END
